function is_login() { // 是否登录
	return parseInt(MID);
}
function url(url, params, rewrite) { // url解析
	if ( window.Think.MODEL[0] == 2) {
		var website = _ROOT_ + '/';
		url = url.split('/');

		if ( url[0] == '' || url[0] == '@' ) url[0] = APPNAME;
		if ( !url[1] ) url[1] = 'Index';
		if ( !url[2] ) url[2] = 'index';
		website = website + '' + url[0] + '/' + url[1] + '/' + url[2];

		if ( params ) {
			params = params.join('/');
			website = website + '/' + params;
		}
		if ( !rewrite ) website = website + '.html';
	} else {
		var website = _ROOT_ + '/index.php';
		url = url.split('/');
		if ( url[0] == '' || url[0] == '@' ) url[0] = APPNAME;
		if ( !url[1] ) url[1] = 'Index';
		if ( !url[2] ) url[2] = 'index';
		website = website + '?s=/' + url[0] + '/' + url[1] + '/' + url[2];
		if ( params ) {
			params = params.join('/');
			website = website + '/' + params;
		}
		if ( !rewrite ) website = website + '.html';
	}

	if ( typeof (window.Think.MODEL[1]) != 'undefined') website = website.toLowerCase();
	return website;
}
function playsound(file) { // 播放背景音乐
	if ( window.Think.ROOT == '' ) {
		file = '/' + file;
	} else {
		file = window.Think.ROOT + '/' + file;
	}

	$('embed').remove();
	$('body').append('<embed src="' + file + '" autostart="true" hidden="true" loop="false">');
	var div = document.getElementById('music');
	div.src = file;
}
function friendlyDate(sTime, cTime) { // 友好时间
	var formatTime = function (num) {
		return (num < 10) ? '0' + num : num;
	};

	if ( !sTime ) return '';

	var cDate = new Date(cTime * 1000);
	var sDate = new Date(sTime * 1000);
	var dTime = cTime - sTime;
	var dDay = parseInt(cDate.getDate()) - parseInt(sDate.getDate());
	var dMonth = parseInt(cDate.getMonth() + 1) - parseInt(sDate.getMonth() + 1);
	var dYear = parseInt(cDate.getFullYear()) - parseInt(sDate.getFullYear());

	if ( dTime<60 ) {
		if ( dTime<10 ) {
			return '刚刚';
		} else {
			return parseInt(Math.floor(dTime / 10) * 10) + '秒前';
		}
	} else if ( dTime<3600 ) {
		return parseInt(Math.floor(dTime / 60)) + '分钟前';
	} else if ( dYear===0 && dMonth===0 && dDay===0 ) {
		return '今天' + formatTime(sDate.getHours()) + ':' + formatTime(sDate.getMinutes());
	} else if ( dYear===0 ) {
		return formatTime(sDate.getMonth() + 1) + '月' + formatTime(sDate.getDate()) + '日 ' + formatTime(sDate.getHours()) + ':' + formatTime(sDate.getMinutes());
	} else {
		return sDate.getFullYear() + '-' + formatTime(sDate.getMonth() + 1) + '-' + formatTime(sDate.getDate()) + ' ' + formatTime(sDate.getHours()) + ':' + formatTime(sDate.getMinutes());
	}
}
function handleAjax(a) { // 处理ajax返回结果
	if ( a.url ) a.info += '，页面即将跳转～'; // 如果需要跳转的话，消息的末尾附上即将跳转字样

	if ( a.status ) { // 弹出提示消息
		toast.success(a.info, L('_KINDLY_REMINDER_'));
	} else {
		toast.error(a.info, L('_KINDLY_REMINDER_'));
	}

	var interval = 1500; // 需要跳转的话就跳转
	if ( a.url == "refresh" ) {
		setTimeout(function () {
			location.href = location.href;
		}, interval);
	} else if ( a.url ) {
		setTimeout(function () {
			location.href = a.url;
		}, interval);
	}
}